﻿package fui.utils.calendar{
	import flash.events.*;
	import flash.display.Sprite;
	import fl.controls.*;
	import fl.containers.ScrollPane;
	import flash.text.TextFormat;
	
	public class CDay extends Sprite{
		private var _day:int;
		private var _dPane:ScrollPane;
		public function CDay(day:int, xpos:int, ypos:int){
			
			this._day = day;
			x = xpos;
			y = ypos;
			_dPane = new ScrollPane();
			//_dPane.x = 1;
			//_dPane.y = 1;
			//_dPane.setSize(40, 40);
			var dlabel:Label = new Label();
			dlabel.text = String(day);
			
			//_dPane.opaqueBackground = 0.6;
			_dPane.addChild(dlabel);
			
			dlabel.width = 65;
			dlabel.height = 65;
			var format:TextFormat = new TextFormat();
          	//format.font		      = "foo";
          	format.color          = 0x00AA00;
          	format.size           = 45;
			format.bold = true;
			dlabel.setStyle("textFormat", format);
			addChild(_dPane);
			setupDay();
		}
		private function setupDay():void{
			_dPane.addEventListener(MouseEvent.CLICK, onDayClickEv);
		}
		private function onDayClickEv(e:MouseEvent):void {
			//TODO: Change color
			_dPane.opaqueBackground = 0.2;
			dispatchEvent(new Event(MouseEvent.CLICK));
		}
	}
}